package top.fangw.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.fangw.admin.pojo.dto.RoleDto;
import top.fangw.admin.pojo.entity.SysRole;
import top.fangw.admin.pojo.entity.SysRoleJoinMenu;
import top.fangw.admin.service.ISysRoleService;
import top.fangw.common.api.vo.InitRoleVo;
import top.fangw.common.api.vo.InitTenantApplication;
import top.fangw.common.core.result.Result;

/**
 * <p>
 * 用途：用于存放系统的角色信息 前端控制器
 * </p>
 *
 * @author fangw
 * @since 2024-03-02
 */
@Tag(name = "角色信息管理")
@RestController
@RequestMapping("/sys-role")
@RequiredArgsConstructor
public class SysRoleController {

    private final ISysRoleService sysRoleService;

    @Operation(summary = "初始化租户角色信息-远程调用")
    @PostMapping("/initTenantRole")
    public Result<InitRoleVo> initTenantRole(@RequestBody InitRoleVo initRoleVo) {
        return Result.success(sysRoleService.initTenantRole(initRoleVo));
    }

    @Operation(summary = "添加角色")
    @PostMapping("/add")
    public Result<?> add(@RequestBody SysRole sysRole) {
        sysRoleService.add(sysRole);
        return Result.success();
    }
}
